using System.Collections.Generic;
using System.Xml.Linq;

namespace EPPlayer
{
    /// <summary>
    /// Keep Skill, Stat and Aptitude modifiers in unparsed XML to avoid
    /// translating them into temporary classes; Modifiers get applied in
    /// GameResources.AttachModifiers()
    /// </summary>
    public class Modifiers
    {
        public readonly IEnumerable<XElement> Aptitude;
        public readonly IEnumerable<XElement> AptitudeMax;
        public readonly IEnumerable<XElement> Skill;
        public readonly IEnumerable<XElement> Stat;
        private Modifiers(
            IEnumerable<XElement> Aptitude,
            IEnumerable<XElement> AptitudeMax,
            IEnumerable<XElement> Skill,
            IEnumerable<XElement> Stat)
        {
            this.Aptitude = Aptitude;
            this.AptitudeMax = AptitudeMax;
            this.Skill = Skill;
            this.Stat = Stat;
        }
        internal static Modifiers Parse(XElement Xml)
        {
            IEnumerable<XElement> Xml1 = Xml.Descendants("aptmod");
            IEnumerable<XElement> Xml2 = Xml.Descendants("aptitudeMax");
            IEnumerable<XElement> Xml3 = Xml.Descendants("skillmod");
            IEnumerable<XElement> Xml4 = Xml.Descendants("statmod");
            return new Modifiers(Xml1, Xml2, Xml3, Xml4);
        }
    }
}